<template>
  <div :class="['collaps-frame', {'collaps-expand':expand.flag}]">
    <div class="collaps-item" @click="expand.flag=!expand.flag;$emit(expand.event,$event)">
      <i :class="['collaps-item-icon',expand.icon]" :title="expand.hint" />
      <span v-show="expand.flag">{{ expand.name }}</span>
    </div>
    <div class="collaps-item-space" />
    <div v-for="(item,index) in menuList" :key="index" class="collaps-item" @click="$emit(item.event,$event)">
      <i :class="['collaps-item-icon',item.icon]" :title="item.hint" />
      <span v-show="expand.flag">{{ item.name }}</span>
    </div>
  </div>
</template>
<script>
export default {
  name: 'CollapsH',
  props: {
    data: {
      type: Object,
      default: () => null
    }
  },
  data() {
    return {
      expand: {
        flag: false,
        icon: 'fa fa-bars',
        hint: '展开',
        name: '开始',
        event: 'toggle'
      }
    }
  },
  computed: {
    menuList() {
      return [{
        icon: 'fa fa-user',
        hint: this.data.id || '帐户',
        name: this.data.name || '帐户名称',
        event: 'userConfig'
      }, {
        icon: 'fa fa-cog',
        hint: '设置',
        name: '系统设置',
        event: 'systemConfig'
      }, {
        icon: 'fa fa-sign-out-alt',
        hint: '注销',
        name: '帐户注销',
        event: 'signOut'

      }]
    }
  }
}
</script>
<style scoped>
.collaps-frame {
  display: flex;
  flex-flow:column nowrap;
  line-height: 2rem;
  font-size: 1rem;
  color: #fff;
}
.collaps-item {
  flex-basis: 2rem;
}
.collaps-item-space {
  flex-grow: 1;
}
.collaps-item-icon {
  width: 3rem;
  text-align: center;
}
.collaps-expand {
  width: 100%;
}
.collaps-item:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}
</style>
